package com.ruoyi.web.controller.teacher;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.domain.BasisPositionUser;
import com.ruoyi.dto.BasisCaseLoadingTaskZhuser;
import com.ruoyi.dto.BasisPositionResourceInfoUser;
import com.ruoyi.service.BasisPositionUserService;
import com.ruoyi.service.IBasisCaseLoadingService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/positionUser")
public class BasisPositionUserController {

    @Autowired
    BasisPositionUserService basisPositionUserService;

    @Autowired
    IBasisCaseLoadingService basisCaseLoadingService;

    @GetMapping("/findByLoadingIdFromPositionUser")
    public AjaxResult findByLoadingIdFromPositionUser(String loadingId){
        return AjaxResult.success(basisPositionUserService.findByLoadingIdFromPositionUser(loadingId));
    }

    @GetMapping("/findByLoadingIdFromPositionUserRole")
    public AjaxResult findByLoadingIdFromPositionUserRole(String loadingId,Integer deptId){
        return AjaxResult.success(basisPositionUserService.findByLoadingIdFromPositionUserRole(loadingId,deptId));
    }

    @GetMapping("/findByLoadingIdFromPositionUserRoleAll")
    public AjaxResult findByLoadingIdFromPositionUserRoleAll(String loadingId){
        return AjaxResult.success(basisPositionUserService.findByLoadingIdFromPositionUserRoleAll(loadingId));
    }


    @PostMapping("/addBasisCaseLoadingTaskZhuser")
    public AjaxResult addBasisCaseLoadingTaskZhuser(@RequestBody BasisCaseLoadingTaskZhuser basisCaseLoadingTaskZhuser){
        return AjaxResult.success(basisPositionUserService.addBasisCaseLoadingTaskZhuser(basisCaseLoadingTaskZhuser));
    }

    @GetMapping("/configBasisTaskZhuserIssued")
    public AjaxResult configBasisTaskZhuserIssued(Integer taskId){
        return AjaxResult.success(basisPositionUserService.configBasisTaskZhuserIssued(taskId));
    }


    @PostMapping("/updateBasisTaskZhuser")
    public AjaxResult updateBasisTaskZhuser(@RequestBody BasisCaseLoadingTaskZhuser basisCaseLoadingTaskZhuser){
        return AjaxResult.success(basisPositionUserService.updateBasisTaskZhuser(basisCaseLoadingTaskZhuser));
    }

    //根据指挥人员查询案例信息
    @GetMapping("/findByUsuerRoleIdFromloading")
    public AjaxResult findByUsuerRoleIdFromloading(Integer userId){
        return AjaxResult.success(basisCaseLoadingService.findByUsuerRoleIdFromloading(userId));
    }

    @PostMapping("/configUserContent")
    public AjaxResult configUserContent(@RequestBody BasisPositionResourceInfoUser basisPositionResourceInfoUser)
    {
        return AjaxResult.success(basisPositionUserService.configUserContent(basisPositionResourceInfoUser));
    }

    //清空上次演训结果
    @GetMapping("/clearPerformanceTraining")
    public AjaxResult clearPerformanceTraining(String loadingId){
        return AjaxResult.success(basisPositionUserService.clearPerformanceTraining(loadingId));
    }

}
